﻿using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitDimensionText.DimCreator;

namespace YJKRevitDimensionText.Utility
{
	public class RequestHandler : IExternalEventHandler
	{
		public Request Request
		{
			get
			{
				return this.m_request;
			}
		}

		public string GetName()
		{
			return "Dimension Hide External Event";
		}

		public void Execute(UIApplication uiapp)
		{
			try
			{
				RequestId id = this.Request.Take();
				bool isHide = RevitApplication.thisApp.IsHide;
				DimensionHide dimensionHide = new DimensionHide(uiapp);
				switch (id)
				{
				case RequestId.None:
					return;
				case RequestId.ViewTwoPoint:
					dimensionHide.Excute(id, isHide);
					break;
				case RequestId.SelectTwoPoint:
					dimensionHide.Excute(id, isHide);
					break;
				case RequestId.ViewDoorWin:
					dimensionHide.Excute(id, isHide);
					break;
				case RequestId.SelectDoorWin:
					dimensionHide.Excute(id, isHide);
					break;
				case RequestId.ViewWallThick:
					dimensionHide.Excute(id, isHide);
					break;
				case RequestId.SelectWallThick:
					dimensionHide.Excute(id, isHide);
					break;
				case RequestId.ViewAxis:
					dimensionHide.Excute(id, isHide);
					break;
				case RequestId.SelectAxis:
					dimensionHide.Excute(id, isHide);
					break;
				}
			}
			finally
			{
				RevitApplication.thisApp.WakeFormUp();
			}
		}

		private Request m_request = new Request();

		private delegate void DoorOperation(FamilyInstance e);
	}
}
